<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>工作台</title>
    <link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
    <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
    <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
    <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">

    <script src="http://i.gtimg.cn/qzone/biz/gdt/lib/jquery/jquery-2.1.4.js?max_age=31536000"></script>
    <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>

    <script src='https://cdn.bootcss.com/jquery.form/4.2.2/jquery.form.min.js'></script>
    <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
    <script type="text/javascript" src="/webapp/js/lib/jquery.global.settings.js"></script>
    <script type="text/javascript" src="/webapp/js/common/metadata.js"></script>
    <script type="text/javascript" src="/webapp/js/common/config.js"></script>
    <script type="text/javascript" src="/webapp/js/common/workshop.js"></script>
    <script type="text/javascript" src="/webapp/js/common/cities.js"></script>
    <script type="text/javascript" src="/webapp/js/lib/xlsx.full.min.js"></script>
    <script type="text/javascript" src="/webapp/js/common/export.js"></script>
</head>
<body>
<div class="easyui-container-fluid">
    <div class="easyui-panel" style="width:100%;overflow-x: auto;border:none;">
        <div id="nav" class="nav"></div>
        <div class="easyui-panel" style="width:100%;border:none;">
            <form id="ff">
                <div style="margin-bottom:20px;">
                    </select><label class="item-label">年份：</label>
                    <select class="easyui-combobox year" id="year"  name="year" data-options="panelHeight:'150'" style="width:100px;">
                    </select>
                    <label class="item-label">原始品类：</label>
                    <input type="text" name="originalCategory" class="easyui-textbox" style="width:100px;"/>
                    <label class="item-label">品牌码：</label>
                    <input type="text" name="brandCode" class="easyui-textbox" style="width:100px;"/>
                    <label class="item-label">品类：</label>
                    <input type="text" id="categorySelect" name="categoryCode" class="easyui-combobox" data-options="panelHeight:'150'" style="width:100px;"/>
                    <label class="item-label">品类标记：</label>
                    <select  name="recordMark" class="easyui-combobox"  data-options="panelHeight:'150'" style="width:100px;">
                        <option value="">-请选择-</option>
                        <option value="auto">auto(模糊)</option>
                        <option value="exact">exact(精确)</option>
                        <option value="alias">alias(别名)</option>
                        <option value="sku">sku</option>
                        <option value="系">系</option>
                        <option value="套">套</option>
                        <option value="copy">copy</option>
                        <option value="复">复</option>
                        <option value="转">转</option>
                        <option value="合">合</option>
                        <option value="周">周</option>
                        <option value="供">供</option>
                        <option value="wholesale">批发数据</option>
                        <option value="销量还原">销量还原</option>
                        <option value="销量转移">销量转移</option>
                        <option value="价格处理">价格处理</option>
                        <option value="价格还原">价格还原</option>
                        <option value="均价处理">均价处理</option>
                        <option value="电商调价">电商调价</option>
                        <option value="渠道调价">渠道调价</option>
                        <option value="异常价处理">异常价处理</option>
                        <option value="一键调量">一键调量</option>
                        <option value="EXIST">EXIST</option>
                        <option value="Top">Top系列</option>
                        <option value="Top1">Top1</option>
                        <option value="Top4">Top4</option>
                        <option value="Top套4">Top套4</option>
                    </select>
                    <label class="item-label">状态：</label>
                    <input id="entityStatus" class="easyui-switchbutton" checked style="width:80px;height:30px;" onText="启用" offText="禁用"  >

                    <label class="item-label">套餐数据：</label>
                    <input id="comboData" name="comboData" class="easyui-switchbutton" style="width:60px;height:30px;" >
                    <input type="text" class="easyui-textbox" style="width: 30px" id="minNum"  value="0.5" style="width:80px;height:30px;" />
                    <input type="text" class="easyui-textbox" style="width: 30px" id="maxNum"  value="1.8" style="width:70px;height:30px;" />
                    <input type="button" class="easyui-linkbutton" onclick="batchUpdatePrice()" value="一键调价" style="height: 32px;width:70px;background:#cde5fd"/>
                    <label class="item-label">套餐码：</label>
                    <input type="text" name="comboCode" class="easyui-textbox" style="width:100px;"/>
                </div>
                <div style="margin-bottom:20px;" id="parent">
                    <label id="label-for-month" class="item-label-wrap">月：<input type="text" class="easyui-combobox displayWM" id="month" name="month" style="width:100px;"/></label>
                    <label id="label-for-week" class="item-label-wrap">周：<input type="text" class="easyui-combobox displayWM" id="week" name="week" style="width:100px;"/></label>
                    <label class="item-label" id="label-for-mall" >商场码：</label>
                    <input type="text" id="mallSelect" name="mallCode" class="easyui-textbox" data-options="panelHeight:'150'" style="width:100px;"/>
                    <label class="item-label">原始品牌：</label>
                    <input type="text" name="originalBrand" class="easyui-textbox" style="width:100px;"/>
                    <label class="item-label">型号码：</label>
                    <input type="text" name="modelCode" class="easyui-textbox" style="width:100px;"/>
                    <label class="item-label">原始型号：</label>
                    <input type="text" id="originalModel" name="originalModel" class="easyui-textbox" style="width:100px;"/>
                    <label class="item-label">量|价|额：</label>
                    <input id="dataTotal" class="easyui-switchbutton" style="width:80px;height:30px;" >

                    <label class="item-label">异常类型：</label>
                    <select class="easyui-combobox fl" id="unusualcombobx" name="queryType" data-options="panelHeight:'150'" style="width:200px;">
                        <option value="">-请选择-</option>
                        <option value="Q1">1.0 空型号</option>
                        <option value="Q1_1">1.1 手工标记空型号</option>
                        <option value="Q2">1.2 空型号非套餐</option>
                        <option value="Q3">1.3 销量不等于0</option>
                        <option value="Q4">1.4 销量异常</option>
                        <option value="Q5">1.5 销价异常</option>
                        <option value="Q12">1.6 非空型号</option>
                        <option value="Q17">1.7 全品类空型号</option>
                        <option value="Q6">2.0 商场缺失</option>
                        <option value="Q7">2.1 单价或批发价或销量或批发量小于0</option>
                        <option value="Q8">2.2 销量和批发量都等于0</option>
                        <option value="Q9">2.3 单价和批发价都等于0</option>
                        <option value="Q10">2.4 销量大于0,单价等于0</option>
                        <option value="Q11">2.5 批发量大于0,批发价等于0</option>
                        <option value="Q13">3.0 空型号(已处理)</option>
                        <option value="Q14">3.1 非套餐数据</option>
                        <option value="Q15">3.2 套餐数据(未处理)</option>
                        <option value="Q15_1">3.3 套餐数据(已处理)</option>
                        <option value="Q15_2">3.4 套餐数据（空型号）</option>
                        <option value="Q16">3.5 品牌为空</option>
                        <!--<option value="Q17">3.6老旧型号</option> -->
                        <option value="Q18">3.7已禁用型号</option>
                        <option value="Q19">4.0刷单数据</option>
                    </select>
                    <label class="item-label">渠道码：</label>
                    <select id="channelcomparer" name="channelcomparer" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:53px;" prompt="比较符">
                        <option value="EQUAL"  selected = "selected" >=</option>
                        <option value="NOT_EQUAL"><pre><></pre></option>
                        <option value="QZ"><pre>系列</pre></option>
                    </select>
                    <input type="text" id="channelSelect" name="channelCode" class="easyui-textbox" style="width:93px;"/>
                    <!--<input type="button" class="easyui-linkbutton" onclick="exportNoneData()" value="导出空型号" style="margin-left:44px;height: 32px;width:90px;background:#cde5fd"/>-->
                    <!--<input type="button" class="easyui-linkbutton" onclick="ImportNoneData()" value="上传空型号" style="height: 32px;width:90px;background:#cde5fd"/>-->
                </div>
            </form>
            <form id="filterff">
                <div style="margin-bottom:20px;">
                    <label class="item-label">筛选条件：</label>
                    <select id="columnbox" name="column" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:100px;">
                        <option value="">-请选择-</option>
                        <option value="PRICE">价格</option>
                        <option value="COUNT">销量</option>
                        <option value="WHOLE_COUNT">批发量</option>
                        <option value="WHOLE_PEICE">批发价</option>
                        <option value="ORIGINAL_PRICE">原价</option>
                        <option value="AVG_PRICE">均价</option>
                        <option value="DISCOUNT">现价/均价</option>
                        <option value="DISCOUNT2">原价/现价</option>
                    </select>
                    <select id="comparerbox" name="comparer" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:100px;" prompt="比较符">
                        <option value=""></option>
                        <option value="EQUAL">=</option>
                        <option value="GREAT_EQUAL">&gt;=</option>
                        <option value="GREAT">&gt;</option>
                        <option value="LITTLE">&lt;</option>
                        <option value="LITTLE_EQUAL">&lt;=</option>
                        <option value="NOT_EQUAL"><pre><></pre></option>
                    </select>
                    <input type="text" id="valuebox" name="value" class="easyui-textbox" prompt="数值" data-options="" style="width:60px;"/>
                    <select id="columnbox2" name="column" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:100px;">
                        <option value="">-请选择-</option>
                        <option value="PRICE">价格</option>
                        <option value="COUNT">销量</option>
                        <option value="WHOLE_COUNT">批发量</option>
                        <option value="WHOLE_PEICE">批发价</option>
                        <option value="ORIGINAL_PRICE">原价</option>
                        <option value="AVG_PRICE">均价</option>
                        <option value="DISCOUNT">现价/均价</option>
                        <option value="DISCOUNT2">原价/现价</option>
                    </select>
                    <select id="comparerbox2" name="comparer" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:100px;" prompt="比较符">
                        <option value=""></option>
                        <option value="EQUAL">=</option>
                        <option value="GREAT_EQUAL">&gt;=</option>
                        <option value="GREAT">&gt;</option>
                        <option value="LITTLE">&lt;</option>
                        <option value="LITTLE_EQUAL">&lt;=</option>
                        <option value="NOT_EQUAL"><pre><></pre></option>
                    </select>
                    <input type="text" id="valuebox2" name="value" class="easyui-textbox" prompt="数值" data-options="" style="width:60px;"/>
                    <div id="categorywrapper" style="display:inline-block;"></div>
                    <input id="totalStatus" name="totalStatus" style="display: none" value="true"/>  <!-- 用来标记是否查询总数 -->
                    <a class="easyui-linkbutton c8" href="javascript:void(0);" onclick="searchBy()" style="width:80px;margin-left: 10px;">查询</a>&nbsp;&nbsp;
                </div>
            </form>
        </div>

        <div id="upmall" class="easyui-window upload-wrapper" title="上传文件" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:400px;height:250px;padding:10px;">
            <form id="file_form" action="" enctype="multipart/form-data"method="post">
                <div style="margin-bottom:20px;margin-top: 20px;">
                    <input type="file" multiple="multiple" name="file" id="file_input" class="item-label"style="margin-top: 33px;margin-left: 64px;width: 280px;" />
                </div>
                <div style="margin-bottom:20px;margin-top: 60px;text-align:center">
                    <input type="button" value="文件上传" name="Submit" id='sub' style="height: 40px;width: 100px;font-size: 18px;" class="easyui-linkbutton c8">
                </div>
            </form>
        </div>
        <div style="display:flex;border:none;">
            <div class="easyui-panel" style="float:left;flex:none;width:300px;min-height: 609px;padding-left:2px;">
                <h3 style="font-size: 14px;">品牌/型号查询</h3>
                <label>品牌：</label>
                <div>
                    <input type="text" id="brandName" class="easyui-textbox" style="width:160px;" prompt="请输入品牌"/>
                </div>
                <label>型号：</label>
                <div>
                    <input type="text" id="modelName" class="easyui-textbox"  style="width:160px;" prompt="请输入型号"/>
                </div>

                <div style="margin-top:5px;">
                    <input type="text" id="orderId"  value="1" class="input-small" style=""/>
                </div>
                <div id="currentRecord"></div>
                <div id="left-side" class="list-wrapper" style="overflow-y:auto;max-height:444px;">
                    <ul id="similarmodel-list">
                    </ul>
                </div>
            </div>
            <div class="table-wrapper" style="flex:1;float:right;border: none;width: 1420px;">
                <div id="th">
                    <div class="column-list-select" id="column-list-select">
                        <label for="analyzecategory"><input id="analyzecategory" type="checkbox" checked/>系统分析品类</label>
                        <label for="brandCode"><input id="brandCode" type="checkbox" checked/>品牌编码</label>
                        <label for="modelCode"><input id="modelCode" data-options="editor:{type:'numberbox'}" type="checkbox" checked />型号编码</label>
                        <label for="brandmodel"><input id="brandmodel" type="checkbox" checked/>品牌型号</label>
                        <label for="namemodel"><input id="namemodel" type="checkbox" checked/>原名称型号</label>
                        <label for="comboRemark"><input id="comboRemark" type="checkbox" checked/>套餐备注</label>
                        <label for="channelName"><input id="channelName" type="checkbox" checked/>渠道</label>
                        <label for="amounts"><input id="amounts" type="checkbox" checked/>原/现/批发量</label>
                        <label for="prices"><input id="prices" type="checkbox" checked/>原/现/均价</label>
                        <label for="mallName"><input id="mallName" type="checkbox" checked/>商场</label>
                        <label for="user"><input id="user" type="checkbox" checked/>操作人</label>
                    </div>
                    <form id="updateff">
                        <div class="toolbar" style="border:1px solid #95B8E7;">
                            <input type="button" class="easyui-linkbutton" value="启用" onclick="enableAll()" style="height: 32px;width: 48px;"/>
                            <input type="button" class="easyui-linkbutton" value="禁用" onclick="disableAll()" style="height: 32px;width: 48px;"/>
                            <input type="button" class="easyui-linkbutton" value="合并" onclick="joinAll()" style="height: 32px;width: 48px;"/>
                            <input type="button" id="merge" class="easyui-linkbutton" value="合并Plus" onclick="autoMerge()" style="height: 32px;width: 57px;"/>
                            <input type="button" class="easyui-linkbutton" value="标记批发" onclick="markWholesale()" style="height: 32px;width: 60px;"/>
                            <input type="button" class="easyui-linkbutton" value="取消批发" onclick="cancelWholesale()" style="height: 32px;width: 60px;"/>
                            <input type="button" class="easyui-linkbutton" value="复制" onclick="cloneOne()" style="height: 32px;width: 48px;"/>
                            <select class="easyui-combobox" name="markType" data-options="panelHeight:'auto'" style="width: 64px;">
                                <option value="model" selected="selected">型号</option>
                                <option value="brand">品牌</option>
                            </select>
                            <input type="text" id="markValue" name="markValue" class="easyui-textbox" style="width: 100px"/>
                            <input type="button" class="easyui-linkbutton" onclick="mark()" value="标记" style="height: 32px;width:48px;"/>
                            <div id="SettingModelWrapper" style="display: inline-block;"></div>
                            <input type="button" class="easyui-linkbutton" value="设置空型号" onclick="setEmptyModel()" style="height: 32px;width:80px;"/>
                            <input type="button" class="easyui-linkbutton" value="取消空型号" onclick="cancelEmptyModel()" style="height: 32px;width:80px;"/>
                            <input type="text" class="easyui-textbox" name="pct" value="20" style="width:36px;"/>%&nbsp;年
                            <input type="text" name="year"  class="easyui-textbox  displayYear"  value="" style="width:50px"/>
                            <label id="label-month">月</label><label id="label-week">周</label>
                            <input type="text" name="periods"  class="easyui-textbox  displayMW"  value="" style="width:90px"/>
                            |
                            <select class="easyui-combobox" id="thisPeriod" data-options="panelHeight:'auto'" style="width: 78px;">
                                <option value="false" selected="selected">非当期</option>
                                <option value="true">当期</option>
                            </select>
                            <input type="text" class="easyui-textbox" style="width: 30px" id="top"  value="10"/>
                        <input type="button" class="easyui-linkbutton" value="处理空型号" onclick="handleEmptyModel()" style="height: 32px;width:80px;"/>
                </div>
                        <div class="toolbar">
                            <select id="changeTo" name="updateType" class="easyui-combobox" style="width:174px;"  prompt="请选择调整方式">
                                <option value=""></option>
                                <option value="T1">1.1 手动调成(整数)</option>
                                <option value="T2">1.2 手动调成(系数)</option>
                                <!--<option value="T3">1.3 手动调整(不移批发)</option>-->
                                <!--<option value="T4">1.4 批发移零售</option>-->
                                <!--<option value="T5">2.1 无型号</option>-->
                                <!--<option value="T6">2.2 型号不全</option>-->
                                <!--<option value="T7">2.3 其他</option>-->
                                <!--<option value="T8">3.1 不保留</option>-->
                                <option value="T9">3.2 个位保留</option>
                                <option value="T10">3.3 十位保留</option>
                                <option value="T11">3.4 百位保留</option>
                                <option value="T12">4.1 撤销更改销量</option>
                                <option value="T13">4.2 撤销更改价格</option>
                                <!--<option value="T14">4.3 更改商场码</option>-->
                                <!--<option value="T15">4.4 更改渠道码</option>-->
                                <!--<option value="T16">5.1 批发量=0</option>-->
                                <!--<option value="T17">5.2 批发价=0</option>-->
                                <!--<option value="T18">5.3 单价=0</option>-->
                                <option value="T19">5.4 单价=单价/销量</option>
                                <option value="T20">5.5 单价=单价*销量</option>
                                <option value="T21">5.6 单价=单价-整数</option>
                                <option value="T22">5.7 单价=单价*系数</option>
                                <option value="T23">5.8 单价=均价*系数</option>
                                <option value="T24">5.9 单价<=均价</option>
                                <!--<option value="T25">5.10 单价<=批发价</option>-->
                                <!--<option value="T26">5.11 电商单价=均价*系数</option>-->
                                <!--<option value="T27">5.12 批发价<=单价</option>-->
                                <option value="T28">5.13 销量=销量*系数</option>
                                <!--<option value="T29">5.14 单价=指定数*系数</option>-->
                            </select>
                            <input type="text" id="number" name="number" class="easyui-textbox" style="width: 60px" prompt="指定数" />
                            <input type="text" id="changeValue" name="changeValue" class="easyui-textbox"  style="width: 60px" prompt="数值"/>
                            <input type="button" class="easyui-linkbutton" onclick="adjustment()" value="调整" style="height: 32px;width:48px;"/>

                            <input class="easyui-combobox" name="categoryCode" id="categorybox" data-options="panelHeight:150" style="width:128px;"/>
                            <input type="button" class="easyui-linkbutton" onclick="moveTo()" value="转移" style="height: 32px;width:48px;"/>
                            <div id="comboWrapper" style="display:inline-block">
                                <label><input type="checkbox" name="categoryCode2" value="07"/>油烟机</label>
                                <label><input type="checkbox" name="categoryCode2" value="08"/>燃气灶</label>
                                <label><input type="checkbox" name="categoryCode2" value="09"/>消毒柜</label>
                                <label><input type="checkbox" name="categoryCode2" value="10"/>热水器</label>
                                <input type="button" class="easyui-linkbutton" value="标记套餐" onclick="markAsMeal()" style="height: 32px;width:65px;"/>
                                <input type="button" class="easyui-linkbutton" value="取消套餐" onclick="cancelMeal()" style="height: 32px;width:65px;"/>
                                <!--<input type="button" class="easyui-linkbutton" value="拆分套餐原始版本" onclick="splitMeal()" style="height: 32px;width:65px;" id="btn-split"/> splitnew-->
                                <input type="button" class="easyui-linkbutton" value="拆分套餐" onclick="splitMeal()" style="height: 32px;width:68px;" id="btn-split"/>
                            </div>

                            <input type="text" name="num" class="easyui-textbox" value="" onclick="" style="height: 32px;width:40px;"/>

                            <input type="button" class="easyui-linkbutton" value="大销量拆分" onclick="largeSalesSplit()" style="height: 32px;width:80px;"/>
                            <input type="button" class="easyui-linkbutton" value="追加禁用库" onclick="addDisableMatch()" style="height: 32px;width:80px;"/>
                        </div>
                    </form>
                </div>
                <table id="datagrid" idField="id" style="width:100%;height: 609px" data-options="fitColumns:true,scrollbarSize:0">
                    <thead></thead>
                    <tbody></tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- 填充型号 -->
    <div id="addModelNone" class="easyui-dialog"  style="padding:5px;width:1200px;height:700px;"
         title="填充型号" iconCls="icon-ok"
         toolbar="#dlg-toolbar" buttons="#dlg-buttons" closed="true">
        <div class="easyui-container-fluid">
            <div class="easyui-panel" style="border: none;">
                <div class="easyui-panel" style="border:none;">
                    <form id="filling">
                        <div style="margin-bottom:20px;">
                            <input id="dataId" style="display: none" />
                            <label class="item-label"><span class="item-required">*</span>品类：</label>
                            <select class="easyui-combobox" id="categorySelectAdd" name="categoryCode" style="width:128px;" required="required" >
                            </select>
                            <label class="item-label"><span class="item-required">*</span>品牌：</label>
                            <select class="easyui-combobox" id="brandSelectAdd" name="brandCode" validType="notNull['#brandSelectAdd']" style="width:128px;"  required="required" prompt="--请选择--">
                            </select>
                            <label class="item-label"><span class="item-required">*</span>型号：</label>
                            <input type="text" class="easyui-textbox" name="name" id="modelNameNew" data-options="required:true" prompt="请输入型号"/>
                            <label class="item-label">系列：</label>
                            <input type="text" class="easyui-textbox" name="series" id="series" style="width: 134px"/>
                            <a class="easyui-linkbutton c8" href="javascript:void(0);" onclick="searchBymodelf()" style="width:80px;margin-left: 3px;">型号确认</a>&nbsp;&nbsp;
                        </div>
                        <div>
                            <label class="item-label" style="margin:10px 0;"></span>网页标题：</label>
                            <input type="text" class="easyui-textbox" style="width:444px;height:40px;" data-options="multiline:true"name="title"/>
                            <label class="item-label" style="margin:10px 0;"></span>产品卖点：</label>
                            <input type="text" class="easyui-textbox" style="width:400px;height:40px;" data-options="multiline:true"name="sellMerit"/>
                        </div>
                        <div>
                            <label class="item-label" style="margin:10px 0;"></span>原始型号：</label>
                            <input type="text" class="easyui-textbox" id="originalModelAdd" style="width:444px;"/>
                            <label class="item-label" ><span class="item-required">*</span>规格状态：</label>
                            <select name="propStatus" class="easyui-combobox" style="width: 128px" data-options="required:true,panelHeight:'auto'"  style="width:100px;" >
                                <option value="CONFIRMONE" selected>一级</option>
                                <option value="CONFIRMTWO">两级</option>
                                <option value="CONFIRMTHREE">三级</option>
                                <option value="CONFIRMALL">全部确认</option>
                                <option value="UNCOFIRMED">未确认</option>
                                <option value="UNABLECOFIRED">无法找到信息</option>
                                <option value="UNRELEASED">暂未发布</option>
                            </select>
                        </div>
                        <div style="margin-bottom:20px;">
                            <label class="item-label" style="margin:14px 0;">别名：</label>
                            <input name="otherNames" class="easyui-tagbox" value="" style="width:444px;min-height:30px;" data-options="multiline:true"/>
                        </div>
                        <div style="margin-bottom:10px;">
                            <label class="item-label" >上市年份：</label>
                            <input type="text" class="easyui-numberbox" name="onSellYear" id="onSellYear" />
                            <label class="item-label" ><span class="item-required">*</span>上市价格：</label>
                            <input type="text" class="easyui-numberbox" data-options="required:true" prompt="请输入上市价格" name="onSellPrice"  />
                        </div>
                        <div>
                            <label class="item-label" >上市月：</label>
                            <input type="text" class="easyui-numberbox" name="onSellMonth" id="onSellMonth" />
                            <label class="item-label" >上市周：</label>
                            <input type="text" class="easyui-numberbox" name="onSellWeek" id="onSellWeek"/>
                        </div>
                        <div style="margin-bottom:20px;">
                            <label class="item-label" style="margin:14px 0;">描述：</label>
                            <input type="text" class="easyui-textbox" name="description"  id="description" multiline="true" style="width:444px;height:40px;"/>
                            <a id="tzwy" href="https://www.baidu.com/" onclick="tzwy()" target="_Blank"  style="width:80px;margin-left: 10px;">跳转</a>&nbsp;&nbsp;<!--onclick="tzwy()"-->
                            <a class='l-btn-left l-btn-icon-left' style='width:50px;height: 50px' onclick='copyUrl()'><span class='l-btn-icon icon-copy'></span></a>

                        </div>
                        <div >
                            &nbsp;&nbsp;<span style="font-weight: 900 ;font-size:20px; width: 100px" >规格数据：</span>

                        </div>

                        <div id="categoryMetadataFilling1"></div>
                        <div style="margin-bottom:20px;margin-left:100px;">
                            <a href="javascript:void(0)" class="easyui-linkbutton c8" onclick="submitForm()" style="width:80px">保存</a>
                            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="cancel()" style="width:80px">取消</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    var pageWeek;
    var pageMonth;
    var pageYear;

    var onSellWeekToAdd;
    var onSellMonthToAdd;
    var onSellYearToAdd;
    $(function(){
        initBrandSelect("brandSelectAdd");
        initCategorySelect("categorySelectAdd");
        $("#number").next().hide();
        $("#top").next().hide();
        $(".year").combobox({
            onSelect : function(param){
                $(".displayYear").textbox('setValue',param.code)
            }
        });
        $(".displayWM").combobox({
            onSelect : function(param){
                var mwnew="";
                if(param.code == 1) {
                    if(isMonthType()){
                        mwnew=9+"|"+10+"|"+11+"|"+12
                    }else {
                        mwnew=49+"|"+50+"|"+51+"|"+52
                    }
                    $(".displayYear").textbox('setValue',$(".displayYear").textbox('getValue')-1);
                }else if(param.code ==2){
                    mwnew=1
                }else if(param.code == 3){
                    mwnew=1+"|"+2
                }else if(param.code == 4){
                    mwnew=1+"|"+2+"|"+"3"
                }else {
                    mwnew= (param.code-4)+"|"+(param.code-3)+"|"+(param.code-2)+"|"+(param.code-1)
                }

                $(".displayMW").textbox('setValue',mwnew)
            }
        });
    });
    var globalData = [];
    $(function () {
        initPage();
        setNav();

        var height = $(window).height();
        var nav_height = $("#nav")._outerHeight();
        var ff_height = $("#ff").height()+$("#filterff").height();
        var table_height = height-nav_height-ff_height-20;
        $("#datagrid").css("max-height",table_height);
        var fixedColumns = valueSets(columns_map);
        var dg_columns = fixedColumns;
        var dg = $("#datagrid").datagrid({
            rownumbers:true,
            pagination:true,
            idField:"id",
            checkOnSelect:false,
            columns:[dg_columns],
            onClickRow:function (index,row) {
                window.currentRecord = row;
                leftDirectionFun();    //记得放开
                return false;
            },
            onLoadSuccess:function (data) {
                $("#datagrid").datagrid("clearChecked");
                var stats = "<div class='stats'><label>销量 ：{{totalCount}}</label>&nbsp;&nbsp;&nbsp;<label>金额 ：{{totalPrice}}</label>&nbsp;&nbsp;&nbsp;<label>均价 ：{{avgPrice}}</label></div>";
                stats = stats.replace("{{totalCount}}",globalData.map.totalCount);
                stats = stats.replace("{{totalPrice}}",globalData.map.totalPrice);
                stats = stats.replace("{{avgPrice}}",globalData.map.avgPrice);
                $(".datagrid-wrap").find(".stats").remove();
                //before：在div外的后面加入标签
                $(".datagrid-wrap").find(".datagrid-pager").find(".pagination-info").before(stats);

                $("#b1").remove();
                var totalStatus = $("#totalStatus").val();
                var value = totalStatus == "true" ? "ON" : "OFF";
                var color = totalStatus == "true" ? "black" : "red";
                var b1 = "<input type='button' id='b1' style='color: "+color+"' onclick='method1()' value='" + value + "'>";
                $(".datagrid-wrap").find(".datagrid-pager").find(".pagination-info").append(b1);

            },
            onDblClickCell: function (rowIndex, field, value) {
                var rows = $('#datagrid').datagrid('getRows');
                var row = rows[rowIndex];
                var id = row.id;
            },
            toolbar:"#th"
        }).datagrid("getPager").pagination({
            onSelectPage:searchBy
        });

        $(".column-list-select").delegate("input","click",function(e){
            var self = this;
            var columns = getColumns();
            $("#datagrid").datagrid({
                columns:[columns],
                data:globalData
            });
        });

        var modelName="";
        //监听键盘事件
        $(".table-wrapper").keydown(function (event) {
            var e = event || window.event;
            var keyCode = e.keyCode || e.which;
            if(keyCode=="37"){
                //只是在<input name="model" /> <input name="brand" />下才是光标移动到搜索框
                var type=e.target.name;
                if(type=="model"||type=="brand"){
                    e.preventDefault();
                    $("#modelName").textbox('textbox').focus();
                    // leftDirectionFun();
                    console.log("<-1");
                }else{
                    console.log("<-");
                    var parent = $(e.target).parents("tr");
                    var input_tags = parent.find(".datagrid-text");
                    var index = input_tags.index(e.target);
                    index = index-1;
                    if(index<0){
                        index = 0;
                    }
                    e.preventDefault();
                    input_tags.eq(index).focus();
                    input_tags.eq(index)[0].setSelectionRange(-1,-1);//解决位置的问题
                }

            }else if(keyCode=="38"){
                console.log("^");
                var ele = $(e.target);
                var type = e.target.name;
                var index2 = $("#datagrid").datagrid("getRowIndex",e.target.id);
                index2 = index2-1;
                if(index2<0){
                    index2 = 0;
                }
                var tr = $(".table-wrapper .datagrid-view2 table.datagrid-btable").find("tr").eq(index2);
                tr.find("input[name="+type+"]").focus();
                setTimeout(function () {
                    tr.find("input[name="+type+"]")[0].setSelectionRange(-1,-1);//解决位置的问题
                },10);

            }else if(keyCode=="39"){
                console.log("->");
                var type = e.target.name;
                if(type=="model"){
                    var record = window.currentRecord ;//= $("#datagrid").datagrid("getSelected");
                    if(record){
                        modelName = record.originalModel;
                        selectRowByModelName(modelName);
                    }
                }else{
                    var parent = $(e.target).parents("tr");
                    var input_tags = parent.find(".datagrid-text");
                    var index = input_tags.index(e.target);
                    index = index+1;
                    if(index==input_tags.length){
                        index = 0;
                    }
                    e.preventDefault();
                    input_tags.eq(index).focus();
                    input_tags.eq(index)[0].setSelectionRange(-1,-1);//解决位置的问题
                }

            }else if(keyCode=="40"){
                console.log("v");
                var ele = $(e.target);
                var type = e.target.name;
                var index2 = $("#datagrid").datagrid("getRowIndex",e.target.id);
                var tr = $(".table-wrapper .datagrid-view2 table.datagrid-btable").find("tr").eq(index2+1);
                tr.find("input[name="+type+"]").focus();
                //光标移动做完了
                //修改
                updateCurrentRow(e.target);
            }else if(keyCode=="13"){
                console.log("enter");
            }
        });
        $("#modelName").textbox('textbox').keydown(function (event) {
            var e = event||window.event;
            var keyCode = e.keyCode || e.which;
            if(keyCode=="13"){//回车
                var modelName = $("#modelName").textbox('getValue');
                if(!modelName){
                    //$.messager.alert("提示","请输入型号","warn");
                    return false;
                }else{
                    searchByModel(modelName,e.target);
                }
            }else if(keyCode=="40"){//DW 下键
                console.log("-v");
                $("#orderId").focus();
            }
        });
        $("#orderId").keydown(function (event) {
            var e = event||window.event;
            var keyCode = e.keyCode || e.which;
            if(keyCode=="13"){
                var orderId = $(this).val();
                if(dataForSimilar.length==0){
                    //$.messager.alert("提示","没有可替换的记录","warn");
                    return false;
                }
                if(orderId==""){
                    //$.messager.alert("提示","请输入数值","warn");
                    return false;
                }
                if(isNaN(orderId)){
                    //$.messager.alert("提示","请输入正确的数值","warn");
                    return false;
                }
                if(orderId==0||(orderId>0&&orderId>dataForSimilar.length)){
                    //$.messager.alert("提示","请输入正确的序号","warn");
                    return false;
                }
                var record = dataForSimilar[orderId-1];
                batchReplace(window.currentRecord.id, record.code);
                // $("#originalModel").textbox("setValue","");  取消回车键清除原始型号关键字
                searchBy();
            }else if(keyCode=="40"){
                var orderId = $(this).val();
                if(dataForSimilar.length==0){
                    //$.messager.alert("提示","没有可替换的记录","warn");
                    return false;
                }
                if(orderId==""){
                    //$.messager.alert("提示","请输入数值","warn");
                    return false;
                }
                if(isNaN(orderId)){
                    //$.messager.alert("提示","请输入正确的数值","warn");
                    return false;
                }
                if(orderId==0||(orderId>0&&orderId>dataForSimilar.length)){
                    //$.messager.alert("提示","请输入正确的序号","warn");
                    return false;
                }
                var record = dataForSimilar[orderId-1];
                //update current record
                var url = "/sales/detail/model/moveTo/"+record.code;
                var id = window.currentRecord.id;
                updateModelAndFocus(url,id);
            }
        });
        //表格文本输入框光标事件
        $(".table-wrapper").delegate("input[type=text]","focus",function (e) {
            var index = $("#datagrid").datagrid("getRowIndex",e.target.id);
            window.currentRecord = globalData.content[index];
            leftDirectionFun();
        });
        //input type=text enter
        $("#ff").keydown(function (event) {
            var e = event || window.event;
            var keyCode = e.keyCode || e.which;
            if(keyCode=="13"){
                searchBy();
            }
        });
        /**
         $(".easyui-combobox").combobox({
                onChange:function () {
                    searchBy();
                }
            });**/
    });

    //快捷键⬅️功能
    function leftDirectionFun() {
        var e = event||window.event;
        var record = window.currentRecord;
        if(record){
            var modelName = record.originalModel;
            if(!modelName)return false;
            $("#currentRecord").html("<span>("+record.price+")</span>"+modelName);
            $("#brandName").textbox("setValue",record.brandName);;
            var modelreg = modelName.replace(/[\u4e00-\u9fa5]/g,"");
            modelreg = modelreg.replace(/\ /g,"");
            /*modelreg = modelreg.replace(/\W/g,"+");*/
            // $("#modelName").textbox("setValue",modelreg);
            // searchByModel(modelreg);
            searchByModel(modelreg,e.target);

        }
    }
    function searchBy(page,size) {
        var dtd = $.Deferred();
        var data = getFormData(document.getElementById("ff"));
        data.reportType=window.parent.workMode.toUpperCase();
        pageYear = data.year;
        if (isMonthType()) {
            pageMonth = data.month;
        }else {
            pageWeek = data.week;
            if (!data.week) {
                data.week = window.parent.timeData.weekInYear;
            }
        }
        initOnSellYearMonth();
        var pager = {page:page,size:size};
        if(!size){
            pager['page']= 1;
            pager['size'] = $("#datagrid").datagrid("getPager").pagination("options").pageSize||100;
        }
        var jsonobj = buildJsonObject();
        jsonobj.dataTotal = $("#dataTotal").switchbutton("options").checked;
        jsonobj.entityStatus = $("#entityStatus").switchbutton("options").checked==true?"OK":"DISABLE";
        jsonobj.totalStatus = $("#totalStatus").val();
        jsonobj = $.extend(true,jsonobj,transfer(data));
        jsonobj = JSON.stringify(jsonobj);
        // jsonobj.recordMark="套";
        $.ajax({
            url:config.url + "/sales/detail/page?"+transfer2url(pager),
            type:'post',
            data:jsonobj,
            contentType:"application/json;charset=UTF-8",
            dataType:'json',
            xhrFields:{withCredentials:true},
            beforeSend:function () {
                $.messager.progress({
                    title:"请稍等",
                    interval:30,
                    text:"数据加载中..."
                });
            },
            complete:function () {
                $.messager.progress("close");
            },
            success:function (data) {
                $.messager.progress("close");
                if(data){
                    globalData = data;
                    $("#datagrid").datagrid("loadData",data);
                    dtd.resolve();
                }
            },
            error:function (XMLHttpRequest,textStatus,errorThrown) {

            }
        });
        return dtd.promise();
    }
    function buildJsonObject() {
        var object = {};
        var formdata = getFormData(document.getElementById("filterff"));
        var columns = formdata.column;
        var comparers = formdata.comparer;
        var values = formdata.value;
        var integerFilters = [],floatFilters = [];
        for(var i in columns){
            var column = columns[i];
            var comparer = comparers[i];
            var value = values[i];
            if(column&&comparer&&value&&!isNaN(value)){
                if (column == "DISCOUNT" || column == "DISCOUNT2") {
                    floatFilters.push({column: column, comparer: comparer, value: value});
                } else {
                    integerFilters.push({column: column, comparer: comparer, value: value});
                }
            }
        }
        if(integerFilters&&integerFilters.length>0){
            object.integerFilters = integerFilters;
        }else{
            object.integerFilters = [];
        }

        if(floatFilters&&floatFilters.length>0){
            object.floatFilters = floatFilters;
        }else{
            object.floatFilters = [];
        }

        var metadataFilters = [];
        for(var key in formdata){
            if(!isNaN(key)){
                var prop = key;
                if(!formdata[key])continue;
                metadataFilters.push({code:key,value:formdata[key]});
            }
        }
        if(metadataFilters&&metadataFilters.length>0){
            object.metadataFilters = metadataFilters;
        }else{
            object.metadataFilters = [];
        }
        return object;
    }

    function method1() {
        var b1 = $("#b1").val();
        $("#b1").val(b1 == "ON" ? "OFF" : "ON");
        if(b1=="ON"){
            $("#b1").css("color","red");
            $("#totalStatus").val("false");
        }else {
            $("#b1").css("color","black");
            $("#totalStatus").val("true");
        }
    }

    //--------------------------------------填充型号页面--------------------------------------
    function addProp(categoryCode) {

        $.ajax({
            url:config.url+"/categoryMetadata/getMetadataUnderCategory?categoryCode="+categoryCode,
            type:'get',
            xhrFields:{withCredentials:true},
            success:function (data) {
                //规格数据填充
                var content = generateContent(data,true);
                $("#categoryMetadataFilling1").html(content);
                $.parser.parse($("#categoryMetadataFilling1"));
                var sid = window.currentRecord.id;
                // console.log(sid);
                // initFormDataNone(sid);

                /**
                 * 针对智能门锁进行关联项
                 */

                $(".zw").change(function(a) {
                    if($(".zw").prop('checked')){
                        $("#04774").combobox("setValue","是");
                        // alert("选中");
                        //当前为选中状态
                    }else {
                        $("#04774").combobox("setValue","否");
                        // alert("未选中");
                        //当前为不选中状态
                    }
                });
                $(".mm").change(function(a) {
                    if($(".mm").prop('checked')){
                        $("#04775").combobox("setValue","是");
                        //当前为选中状态
                    }else {
                        $("#04775").combobox("setValue","否");
                        //当前为不选中状态
                    }
                });

                $(".ys").change(function(a) {
                    if($(".ys").prop('checked')){
                        $("#04776").combobox("setValue","是");
                        //当前为选中状态
                    }else {
                        $("#04776").combobox("setValue","否");
                        //当前为不选中状态
                    }
                });
                $(".sk").change(function(a) {
                    if($(".sk").prop('checked')){
                        $("#04777").combobox("setValue","是");
                        //当前为选中状态
                    }else {
                        $("#04777").combobox("setValue","否");
                        //当前为不选中状态
                    }
                });
                $(".app").change(function(a) {
                    if($(".app").prop('checked')){
                        $("#04778").combobox("setValue","是");
                        //当前为选中状态
                    }else {
                        $("#04778").combobox("setValue","否");
                        //当前为不选中状态
                    }
                });
                $(".rlsb").change(function(a) {
                    if($(".rlsb").prop('checked')){
                        $("#04779").combobox("setValue","是");
                        //当前为选中状态
                    }else {
                        $("#04779").combobox("setValue","否");
                        //当前为不选中状态
                    }
                });
                $(".wx").change(function(a) {
                    if($(".wx").prop('checked')){
                        $("#04780").combobox("setValue","是");
                        //当前为选中状态
                    }else {
                        $("#04780").combobox("setValue","否");
                        //当前为不选中状态
                    }
                });
                $(".hm").change(function(a) {
                    if($(".hm").prop('checked')){
                        $("#04781").combobox("setValue","是");
                        //当前为选中状态
                    }else {
                        $("#04781").combobox("setValue","否");
                        //当前为不选中状态
                    }
                });
                $(".zjm").change(function(a) {
                    if($(".zjm").prop('checked')){
                        $("#04782").combobox("setValue","是");
                        //当前为选中状态
                    }else {
                        $("#04782").combobox("setValue","否");
                        //当前为不选中状态
                    }
                });
                $(".ly").change(function(a) {
                    if($(".ly").prop('checked')){
                        $("#04783").combobox("setValue","是");
                        //当前为选中状态
                    }else {
                        $("#04783").combobox("setValue","否");
                        //当前为不选中状态
                    }
                });
            }
        });
    }
    //规格值填充
    function initFormDataNone(id){
        if(id){
            $.ajax({
                url:config.url +"/workshop/getNodeModelByDataId",
                type:'get',
                data:{dataId:id},
                xhrFields:{withCredentials:true},
                success:function(data){
                    //填充表单
                    if(data){
                        var formdata = changeProperty2String(data);
                        if(!formdata.otherNames){
                            formdata.otherNames=[];
                        }
                        if(formdata.properties){
                            var props = formdata.properties;
                            for(var i in props){
                                formdata[props[i].code] = props[i].value;
                                if("boolean"==(typeof props[i].value)){
                                    formdata[props[i].code] = props[i].value.toString();
                                }
                            }
                        }
                        if (!formdata.brandCode) {
                            delete formdata.brandCode;
                        }
                        $("#filling").form("load",formdata);
                        //model brand readonly
                        $("#categorySelectAdd").combobox("readonly",true);
                    }
                },
                error:function(){

                }
            });
        }
        // $("#categorySelectAdd").combobox("select",categoryCode);
    }
    function submitForm(){
        var id=document.getElementById("dataId").value;
        $("#filling").form("submit",{
            onSubmit:function(){
                var valid = $(this).form('enableValidation').form('validate');
                if(!valid)return false;
                var formData = getFormData(document.getElementById("filling"));
                var method = "POST";
                formData.dataId=id;
                if(formData['otherNames'] && typeof formData['otherNames'] === 'string'){
                    formData['otherNames'] = [formData['otherNames']]
                }
                var properties = [];
                for(var i in formData){
                    if(!isNaN(i)&&formData[i]){
                        properties.push({code:i,value:formData[i]});
                    }
                }
                formData['properties'] = properties;
                formData['description'] = $("#description").textbox('getValue');
                //验证系列
                var series = formData["series"];
                var reg = /^(\w|[\u4E00-\u9FA5]|\(|\)|\/|-)*$/;
                if (series) {
                    if (series.length > 20) {
                        $.messager.alert("提示","【系列】长度不能超过20个字符","error");
                        return;
                    }else if(!series.match(reg)){
                        $.messager.alert("提示","【系列】不能含有\"()/-\"以外的特殊符号","error");
                        return;
                    }
                }

                if(formData['onSellPrice']<=0){
                    $.messager.alert("提示","上市价格不能小于等于0","error");
                    return;
                }
                /**
                 * 设置默认的上市年月
                 * 1.若是周报/电商数据，上市周为当前处理的周数，上市月以周数为标准
                 * 2.若是月报数据，上市月为当前处理的月数，上市周以月数最后一周为标准
                 */
                if (!formData['onSellYear']) {
                    formData['onSellYear'] = onSellYearToAdd;
                }
                if (!formData['onSellMonth']) {
                    formData['onSellMonth'] = onSellMonthToAdd;
                }
                if (!formData['onSellWeek']) {
                    formData['onSellWeek'] = onSellWeekToAdd;
                }
                $.ajax({
                    url:config.url+"/workshop/saveModel",
                    type:method,
                    data:JSON.stringify(formData),
                    dataType:'json',
                    contentType:'application/json;charset=UTF-8',
                    xhrFields:{withCredentials:true},
                    beforeSend:function(){
                        $.messager.progress({
                            title:"请稍等",
                            interval:50,
                            text:"操作进行中..."
                        });
                    },
                    complete:function(){
                        $.messager.progress("close");
                    },
                    success:function(data){
                        if(data.code == 200){
                            $.messager.alert("提示",data.msg,"info",function(){
                                // window.parent.closeCurrentTab(true);
                                // $('#filling').form('clear');放到了页面打开前
                                $('#addModelNone').dialog('close');
                                searchBy();
                            });
                        }else{
                            $.messager.alert("错误",data.msg,"error");
                        }
                    },
                    error:function(XMLHttpRequest,textStatus,thrown){
                        $.messager.alert("提示","操作失败","error");
                    }
                });
                return false;
            }
        });
    }
    function cancel(){
        // $('#filling').form('clear');
        $('#addModelNone').dialog('close');

    }
    // 提交上传文件
    $(function() {
        $("#sub").click(function () {
            // var form = new FormData(document.getElementById("file_form"));
            // alert(form);
            $("#file_form").ajaxSubmit({
                xhrFields:{withCredentials:true},
                url:config.url +"/workshop/uploadModelNone",
                type:"POST",
                dataType : "text",
                data:$('#file_form').serialize(),
                processData: false,
                beforeSend:function () {
                    $.messager.progress({
                        title:"请稍等",
                        interval:20,
                        text:"操作进行中..."
                    });
                },
                complete:function () {
                    $.messager.progress("close");
                },
                success : function(data) {
                    $("#upmall").window("close");
                    searchBy();
                    $.messager.alert("提示",data);
                }
            })
        })
    });
    function tzwy() {
        var  wz=$("#description").textbox('getValue');

        document.getElementById("tzwy").href = wz;
    }

    function copyUrl(){
        var  url=$("#description").textbox('getValue');
        var flag = copyText(url);
        $.messager.show({
            title: '提示',
            msg: flag?"网址复制成功":"网址复制失败",
            timeout: 500,
            showType: 'show'
        });
    }
    $("#thisPeriod").combobox({
        onChange:function () {
            var value = $("#thisPeriod").combobox("getValue");
            if(value=="true"){
                $("#top").next().show();
            }else{
                $("#top").next().hide();
            }
        }
    });

    $("#changeTo").combobox({
        onChange:function () {
            var value = $("#changeTo").combobox("getValue");
            if(value=="T29"){
                $("#number").next().show();
            }else{
                $("#number").next().hide();
            }
        }
    });
    /**
     * 初始化型号添加的上市年月
     * 1.若是周报/电商数据，上市周为当前处理的周数，上市月以周数为标准
     * 2.若是月报数据，上市月为当前处理的月数，上市周以月数最后一周为标准
     */
    function initOnSellYearMonth() {
        onSellYearToAdd = pageYear;
        if (isMonthType()) {
            onSellMonthToAdd = pageMonth;
            onSellWeekToAdd = getWeekNumByMonth(onSellYearToAdd, onSellMonthToAdd);
        } else {
            onSellWeekToAdd = pageWeek;
            onSellMonthToAdd = getMonthByWeekNum(onSellYearToAdd, onSellWeekToAdd);
        }
        $('#onSellYear').numberbox({prompt:onSellYearToAdd});
        $('#onSellMonth').numberbox({prompt:onSellMonthToAdd});
        $('#onSellWeek').numberbox({prompt:onSellWeekToAdd});
    }
</script>
</html>